package pe.edu.upc.xcode.food.dao.impl;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import pe.edu.upc.xcode.food.dao.CategoriaplatoDAO;
import pe.edu.upc.xcode.food.domain.Categoriaplato;
@Repository
@Transactional
public class CategoriaplatoDAOImpl implements CategoriaplatoDAO {

    @PersistenceContext
    private EntityManager em;
	
	public CategoriaplatoDAOImpl() {
		// TODO Auto-generated constructor stub
	}

	public Integer save(Categoriaplato object) {
		// TODO Auto-generated method stub
		em.persist(object);
		return 1;
	}

	public Integer update(Categoriaplato object) {
		// TODO Auto-generated method stub
		em.merge(object);
		return 1;
	}

	public Integer detele(Categoriaplato object) {
		// TODO Auto-generated method stub
		return null;
	}

	public Categoriaplato find(Categoriaplato object) {
		// TODO Auto-generated method stub
		return null;
	}

	public List<Categoriaplato> findAll() {		
		Query query = em.createQuery("SELECT cp from Categoriaplato cp where Categoriaplato.estado='A' ");
		List<Categoriaplato> list= query.getResultList();
		return list;
	}

}
